package com.zjljr.stock.controller;

import com.zjljr.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/stock")
public class StockController {

    @RequestMapping("/reduce")
    public String reduce() {
        return "库存扣减成功";
    }

    @Autowired
    private StockService stockService;

    @RequestMapping("/reduceStock")
    public String reduceStock(@RequestParam Integer productId) {
        return stockService.reduceStock(productId)>0 ? "库存扣减成功" : "库存扣减失败";
    }
}
